import { PrismaClient } from '@prisma/client'
import bcrypt from 'bcryptjs'

const prisma = new PrismaClient()

async function resetAdminPassword() {
  try {
    const passwordHash = await bcrypt.hash('admin123456', 10)
    
    const result = await prisma.user.updateMany({
      where: { email: 'admin@test.com' },
      data: { passwordHash }
    })
    
    console.log('Password reset for users:', result.count)
    
    const user = await prisma.user.findUnique({
      where: { email: 'admin@test.com' },
      select: { id: true, loginId: true, email: true, role: true }
    })
    
    console.log('Admin user:', user)
  } catch (error) {
    console.error('Error:', error)
  } finally {
    await prisma.$disconnect()
  }
}

resetAdminPassword()
